import java.util.Arrays;
import java.util.Scanner;



public  class Homework {
    public static void main(String[] args) {

    }
    public static void move(int i,int[] nums){
        for(int j = i;j<nums.length-1;j++) {
            nums[j] = nums[j + 1];
        }
    }
    public static int removeDuplicates(int[] nums) {
       int len = nums.length;
       for(int i = 1;i<len;){
           if(nums[i] == nums[i-1]){
               move(i,nums);
               len--;
           }
           if(nums[i] != nums[i-1]){
               i++;
           }
           else{;}
       }
       return len;
    }
    public static void main10(String[] args) {
        int[] arr = {1,1,2};
        System.out.println(removeDuplicates(arr));
    }
    public static int removeElement(int[] nums, int val) {
        int left = 0;
        int right = nums.length-1;
        while(left<right){
            if(nums[left]!=val && left<right){
                left++;
            }
            if(nums[right] == val && left<right){
                right--;
            }
            if(nums[left] == val && nums[right] != val){
                int temp = nums[left];
                nums[left] = nums[right];
                nums[right] = temp;
            }
        }
        int i = 0,k = 0;
        while(i < nums.length && nums[i++] != val ){
            k++;
        }
        return k;
    }
    public static void main9(String[] args) {
        int[] arr = new int[]{0,1,2,2,3,0,4,2};
        System.out.println(removeElement(arr,2));
    }
    public static int arraySum(int[] array,int len) {
        //编写一个递归程序，求一个一维数组的所有元素的和
        if(len == 1)
            return array[0];
        else
            return arraySum(array,len-1)+array[len-1];
    }

    public static void main8(String[] args) {
        //编写一个递归程序，求一个一维数组的所有元素的和
        int[] arr = {1,2,3,4,5,5,6};
        System.out.println(arraySum(arr, arr.length));
    }
    public static void main7(String[] args) {
       //一对相亲数是指：甲的约数之和等于乙，乙的约数之和等于甲。求1000以内的相亲数
        int i = 1;
        for(;i<=1000;i++){
            int j = 1;
            int sum = 0;
            for(;j<i;j++){
                if(i%j==0){
                    sum+=j;
                }
            }
            int sum2 = 0;
            for(int k = 1;k<sum;k++){
                if(sum%k==0)
                    sum2+=k;
            }
            if(sum2==i) {
                System.out.printf("%d %d\n",i,sum);
            }
        }
    }
    public static void main6(String[] args) {
        //给定一个3乘以3的二维数组，里面的数据随机生成。分别求出两个对角线的元素之和
        int[][] arr = new int[3][3];
        int cout1 = 0 ,cout2 = 0;
        for(int i = 0;i<3;i++){
            int j = 0;
            for(;j<3;j++){
                arr[i][j] = (int)(Math.random()*100)+1;//生成0~100的随机数
                if(i==j){
                    cout1+=arr[i][j];
                }
                if(i+j==2){
                    cout2+=arr[i][j];
                }
            }
        }
        System.out.println(cout1);
        System.out.println(cout2);
    }
    public static int getAge(int age) {
        if (age == 1)
            return 10;
        else
            return getAge(age - 1) + 2;
    }
    public static void main5(String[] args) {
        System.out.println(getAge(5));
    }
    public static void main4(String[] args) {
        char[] ch = {'a', 'b', 'c'};
        int[] ints = {1, 2, 4, 3, 6,};
        Boolean[] b = {true, false, false, true};
        System.out.println(b);
        System.out.println(ch);
        System.out.println(ints);
        String[] str = {"haha", "hehe", "xixi"};
        System.out.println(str);
    }

    public static void main3(String[] args) {
        int[] a = {1, 2, 3, 4, 5, 6};
        int[] b = new int[6];
        b = Arrays.copyOf(a, 4);
        b = Arrays.copyOfRange(a, 4, 6);
        int i = 9;
        i++;
        System.out.println(i);

    }

    static int missingNumber(int[] nums) {
        int ret = 0;
        for (int i = 0; i <= nums.length; i++) {
            int j = 0;
            for (; j < nums.length; j++) {
                if (i == nums[j]) {
                    break;
                }
            }
            if (j == nums.length) {
                ret = i;
                break;
            }
        }
        return ret;
    }

    public static void main2(String[] args) {
        //数组nums包含从0到n的所有整数，但其中缺了一个。请编写代码找出那个缺失的整数。你有办法在O(n)时间内完成吗？
        //输入：[3,0,1]
        //输出：2
    }

    //    public static int fun(int n){
//        if(n==1||n==2)
//            return 1;
//        return fun(n-1)+fun(n-2);
//    }
//
//    public static void main(String[] args) {
//        System.out.println(fun(4));
//    }
    public static void main1(String[] args) {
//    System.out.println(3/2.0);
//    System.out.println('呵');
//    System.out.println("呵呵");
//    byte b = 127;
//    byte b2 = 4;
//    int b3 = b-b2;
//    System.out.println(b3);
//    short s1 = 3;
//    short s2 = 4;
//    int s = s1 + s2;
//    char ch = '？';
//    System.out.println(ch+3);
//    String a = "Hello,";
//    String b = "welcome to my blog.";
//    System.out.println(a);
//    System.out.println(b);
//    System.out.println(a+b);
        int a = 6;
        //法一
        String s1 = a + "";
        //法二
        String s2 = String.valueOf(s1);
        System.out.println(s1);
        System.out.println(s2);
        String str = "100";
        int b = Integer.parseInt(str);
        System.out.println(b);
        String str2 = "A";
        int c = Integer.parseInt(str2, 16);
        System.out.println(c);
    }
}
